package com.kcs.fxmargin.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;

import com.kcs.common.utils.Constant;
import com.kcs.fxmargin.model.CMessage;

public class MessageDao {
	private Logger log = Logger.getLogger(Constant.LOG_FX);

	public List<CMessage> getMessage(Connection conn, PreparedStatement pstm, ResultSet rs) throws Exception {
		StringBuffer sql 			= new StringBuffer();
		List<CMessage> messageList 	= new ArrayList<CMessage>();
		CMessage message			= null;
		
		sql.append(" select * from c_message where active_status = 'A' order by code ");
		
		log.debug("SQL -> " + sql.toString());
		
		pstm = conn.prepareStatement(sql.toString());
		rs = pstm.executeQuery();
		
		while(rs.next()) {
			message = new CMessage();
			
			message.setCode(rs.getString("code"));
			message.setNameEN(rs.getString("name_en"));
			
			messageList.add(message);
		}
		
		return messageList;
	}

}
